package com.fifth.order.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @Author 闫克起
 * @Date 2021/4/29 16:37
 * @Version 1.0
 */
@Configuration
public class SwaggerConfig {

    //获取swagger2的实例对象docket
    @Bean
    public Docket getDocket() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .groupName("")
                .apiInfo(apiInfo())
                .select()//设置哪些包下的类生产api接口文档
                .paths(Predicates.not(PathSelectors.regex("/error")))
                //设置哪些请求路径生产接口文档
               // .paths(PathSelectors.any())
                .build();
        return docket;
    }

    private ApiInfo apiInfo() {
        Contact DEFAULT_CONTACT = new Contact("第五组", "https://www.bilibili.com/video/BV15N4y1c7Lt", "1430930278@qq.com");
        ApiInfo apiInfo = new ApiInfo("员工管理系统API接口文档", "员工管理系统API接口文档", "1.0", "http://www.bing.com",
                DEFAULT_CONTACT, "Apache 2.0",
                "https://www.bilibili.com/video/BV15N4y1c7Lt", new
                ArrayList<VendorExtension>());
        return apiInfo;
    }
}
